package com.ax.center.duplicate;
import org.springframework.scheduling.annotation.Scheduled;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

/**
 * @author gjl
 * @date 2023/7/6 16:55
 */
public class Duplicate {


    @Scheduled(fixedRate = 1000)
    public  void dep()  {

        Runtime run = Runtime.getRuntime();

        try {
            //相对路径
            Process p = run.exec("src/main/resources/duplicate.bat");  //执行exe程序
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset.forName("GBK")));


            Process r = run.exec("src/main/resources/recovery.bat");  //执行exe程序
            BufferedReader ro = new BufferedReader(new InputStreamReader(r.getInputStream(),Charset.forName("GBK")));

//            //检查命令是否执行失败。
//            if (p.waitFor() != 0) {
//                if (p.exitValue() == 1) {//0表示正常结束，1：非正常结束
//                    System.err.println("命令执行失败!");
//                }
//            }
            br.close();
            ro.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        }
}
